#include <pybind11/pybind11.h>
#include <pybind11/eigen.h>
#include <Eigen/Dense>

namespace py = pybind11;

// 求逆函数
Eigen::MatrixXd matrix_inv(const Eigen::MatrixXd& mat) {
    return mat.inverse();
}

// 行列式函数
double matrix_determinant(const Eigen::MatrixXd& mat) {
    return mat.determinant();
}

PYBIND11_MODULE(MATRIX_INV_DET, m) {
    m.doc() = "Eigen matrix inversion and determinant calculation pybind11 extension";
    m.def("matrix_inv", &matrix_inv, "compute the inverse of a square matrix");
    m.def("matrix_det", &matrix_determinant, "compute the determinant of a square matrix");
}